<template>
	<view class="box">
		<uNavbar title="福合元宝" bgColor="transparent"></uNavbar>
		<view class="wrap">
			<view class="wrap_top">
				<view class="tit"  @click="shuoming=true">
					可用福合元宝 <image class="wh" src="/static/image/wh.png" mode=""></image>
				</view>
				<view class="num">
					{{num}}
				</view>
				<view class="line">

				</view>
	
			</view>
			<view class="btn_wrap">
			<!-- 	<view class="btn1" @click="totopup">
					充值
				</view> -->
				<view class="btn2" @click="gofhzz">
					转赠
				</view>
			<!-- 	<view class="btn2" @click="gowithdraw">
					提取
				</view> -->
			</view>
		</view>
		<view class="main">
			<view class="titt">
				福合元宝明细
			</view>
			<view class="main_item" v-for="item in zlist" :key="item.id">
				<view class="main_item_top">
					<view class="main_item_from">
						<text>{{item.from_desc}}</text>
						<text class="c6 f24" v-if="item.from == 3">({{item.remark}})</text>
					</view>
					<view class="main_item_price">
						{{item.amount}}
					</view>
				</view>
				<view class="main_item_bottom">
					<view class="main_item_text">
						余额：{{item.after}}
					</view>
					<view class="main_item_time">
						{{item.create_time}}
					</view>
				</view>
			</view>
			<noDatas :xxxList="zlist" :status="status"></noDatas>
		</view>
		<u-popup :show="shuoming" :round="10" mode="center" bgColor="transparent" @close="shuoming=false" :closeable="true">
			<view class="shuo_content">
			<!-- 	<view class="shuo_tit">
					说明
				</view> -->
				<view class="shuo_txt">
					<rich-text :nodes="info.balance_hf_explain"></rich-text> 
				</view>
			</view>
		</u-popup>
	</view>

</template>

<script>
	import {
		roughList,
		myAccount,
		WithdrawInfo
	} from "../../api/wallet.js"
	export default {
		data() {
			return {
				page: 1,
				size: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				zlist: [],
				isopen: false, //是否开通钱包
				num: "0.00",
				info: {},
				shuoming:false

			}
		},
		onShow() {
			this.getmyAccount()
			this.getlist()
			this.getWithdrawInfo()
		},
		methods: {
			getWithdrawInfo() {
				WithdrawInfo().then(res => {
					this.info = res.data.transfer
				})
			},
			getmyAccount() {
				myAccount().then(res => {
					this.isopen = res.data.switch
					this.num = res.data.balance_hf
				})
			},
			gofhzz() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/ybdonation"
				})
			},
			totopup() {
				if (this.isopen) {
					this.gotopup()
				} else {
					uni.$u.toast("请开通钱包")
				}
			},
			gotopup() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/topupfh"
				})
			},
			gowithdraw() {
				// uni.$u.toast("敬请期待，功能暂未开放")
				if (this.isopen) {
					uni.navigateTo({
						url: "/pagesMy/mywallet/newwithdrawwallet"
					})
				} else {
					uni.$u.toast("请开通钱包")
				}

			},
			getlist() {
				roughList({
					page: this.page
				}).then(res => {
					if (res.code == 1) {
						let list = res.data.data;
						this.zlist = this.page == 1 ? list : this.zlist.concat(list);
						console.log(this.zlist);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
				})
			}
		},
		onReachBottom() {
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.getlist()
			}
		},
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		height: 100vh;
		background: #EDEAE4;
		background-image: url("../../static/image/wallet_bg.png");
		background-size: 750rpx 418rpx;
		background-repeat: no-repeat;
	}

	.wh {
		width: 25rpx;
		height: 25rpx;
		margin-left: 10rpx;
	}
	.shuo_content{
		width: 670rpx;
		margin: 0 auto;
		min-height: 400rpx;
		background-color:#F5ECDF;
		border-radius: 20rpx;
		padding-bottom: 40rpx;
		padding-top: 40rpx;
		.shuo_tit{
			font-weight: 500;
			font-size: 36rpx;
			color: #333;
			text-align: center;
			margin-top: 40rpx;
		}
		.shuo_txt{
			width: 500rpx;
			margin: 0 auto;
			margin-top: 20rpx;
			color: #666;
			font-size: 28rpx;
			line-height: 50rpx;
		}
	}
	.main {
		width: 690rpx;
		margin-top: 40rpx;
		border-radius: 20rpx;
		margin: 0 auto;
		margin-top: 32rpx;
		background: #FFFFFF;
		padding-bottom: 60rpx;

		.titt {
			width: 690rpx;
			text-align: center;
			font-weight: 400;
			font-size: 36rpx;
			color: #333;
			padding-top: 38rpx;
			margin-bottom: 30rpx;

		}

		.main_item {
			width: 690rpx;
			height: 150rpx;
			background: #FFFFFF;
			// border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 0 auto;

			// margin-bottom: 30rpx;
			.main_item_top {
				display: flex;
				justify-content: space-between;

				.main_item_from {
					font-size: 28rpx;
					color: #333;
					margin: 24rpx;
				}

				.main_item_price {
					font-weight: 500;
					font-size: 36rpx;
					color: #A68A64;
					margin: 24rpx;
				}
			}

			.main_item_bottom {
				display: flex;
				justify-content: space-between;

				.main_item_text {
					font-size: 24rpx;
					color: #A6A5AF;
					margin-left: 24rpx;
				}

				.main_item_time {
					font-weight: 400;
					font-size: 24rpx;
					color: #A6A5AF;
					margin-right: 24rpx;
				}
			}
		}
	}

	.wrap {
		width: 690rpx;
		margin: 0 auto;
		min-height: 200rpx;
		background: linear-gradient(180deg, #F2E3CE 0%, rgba(254, 254, 253, 0.27) 47%, #FFFFFF 100%);
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding-bottom: 40rpx;

		.wrap_top {
			width: 690rpx;
			min-height: 152rpx;
			// background-image: url("../../static/image/ddd.png");
			background-size: 690rpx 352rpx;

			.tit {
				font-weight: 400;
				font-size: 36rpx;
				color: #666;
				padding-top: 32rpx;
				margin-left: 32rpx;
			}

			.num {
				margin-top: 22rpx;
				margin-left: 32rpx;
				font-weight: 700;
				font-size: 52rpx;
				color: #333;
			}

			.line {
				width: 620rpx;
				height: 0rpx;
				margin: 0 auto;
				margin-top: 30rpx;
				border-bottom: 2rpx solid rgba(255, 255, 255, 0.1);
			}

			.txt {
				width: 642rpx;
				min-height: 118rpx;
				margin: 0 auto;
				font-weight: 400;
				margin-top: 22rpx;
				font-size: 26rpx;
				color: #999;
			}
		}

		.btn_wrap {
			width: 690rpx;
			margin-top: 40rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;

			.btn1 {
				width: 200rpx;
				height: 64rpx;
				background: linear-gradient(90deg, #AB8E68 0%, #D7BA93 100%);
				box-shadow: 0rpx 8rpx 12rpx 2rpx rgba(59, 8, 71, 0.3);
				border-radius: 536rpx 536rpx 536rpx 536rpx;
				text-align: center;
				line-height: 64rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
			}

			.btn2 {
				width: 200rpx;
				height: 64rpx;
				background: linear-gradient(90deg, #AB8E68 0%, #D7BA93 100%);
				box-shadow: 0rpx 8rpx 12rpx 2rpx rgba(59, 8, 71, 0.3);
				border-radius: 536rpx 536rpx 536rpx 536rpx;
				text-align: center;
				line-height: 64rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}
	}
</style>